import Vue from 'vue';
import Router from 'vue-router';

Vue.use(Router);

// 解决Vue-Router升级导致的Uncaught(in promise) navigation guard问题
const originalPush = Router.prototype.push
Router.prototype.push = function push (location, onResolve, onReject) {
  if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
  return originalPush.call(this, location).catch(err => err)
}
export default new Router({
    mode: 'history',
    routes: [
        {
            path: '/',
            redirect: '/dashboard'
        },
        {
            path: '/',
            component: () => import('../components/common/Home.vue'),
            meta: { title: '自述文件' },
            children: [
                {
                    path: '/dashboard',
                    component: () => import( '../components/page/Dashboard.vue'),
                    meta: { title: '系统首页' }
                },
                {
                    path: '/awards_manage',
                    component: () => import( '../components/page/manage/AwardsManage.vue'),
                    meta: { title: '奖项管理' }
                },
                {
                    path: '/class_manage',
                    component: () => import( '../components/page/manage/ClassManage.vue'),
                    meta: { title: '班级管理' }
                },
                {
                    path: '/class_awards_manage',
                    component: () => import( '../components/page/manage/ClassAwardsManag.vue'),
                    meta: { title: '班级分配' }
                },
                {
                    path: '/user',
                    component: () => import('../components/page/user/User.vue'),
                    meta: { title: '学生管理' }
                },
                {
                    path: '/awards_apply',
                    component: () => import( '../components/page/awards/AwardsApply.vue'),
                    meta: { title: '奖项申请' }
                },
                {
                    path: '/awards',
                    component: () => import( '../components/page/awards/Apply.vue'),
                    meta: { title: '奖项审核' }
                },
                {
                    path: '/user_awards',
                    component: () => import( '../components/page/awards/UserAwards.vue'),
                    meta: { title: '奖项名单' }
                },
                {
                    path: '/awards_his',
                    component: () => import( '../components/page/awards/AwardsHis.vue'),
                    meta: { title: '申请记录' }
                },

                {
                    path: '/my_awards',
                    component: () => import( '../components/page/user/MyAwards.vue'),
                    meta: { title: '申请记录' }
                },
                {
                    path: '/common_info',
                    component: () => import( '../components/page/info/UserInfo.vue'),
                    meta: { title: '个人信息' }
                },
                {
                    path: '/admin_info',
                    component: () => import( '../components/page/info/AdminInfo.vue'),
                    meta: { title: '个人信息' }
                },
                {
                    path: '/statistics',
                    component: () => import( '../components/page/awards/Statistics.vue'),
                    meta: { title: '个人信息' }
                },
                {
                    path: '/404',
                    component: () => import( '../components/page/404.vue'),
                    meta: { title: '404' }
                },
                {
                    path: '/403',
                    component: () => import( '../components/page/403.vue'),
                    meta: { title: '403' }
                },
                {
                    path: '/info',
                    component:()=>import('../components/page/info/Info.vue'),
                    meta:{title:'个人信息'}
                },
            ]
        },
        {
            path: '/login',
            component: () => import( '../components/page/login/Login.vue'),
            meta: { title: '登录' }
        },
        {
            path: '*',
            redirect: '/404'
        }
    ]
});